window.onload = function (){
    vms.addpost()
}
var obj = {}

var vms = new Vue({
    el: '#location',
    data: {
        items: [],
    },
    methods: {
        addpost(){
            axios.get('user.php?act=getaddress').then(e => {
                console.log(e.data)
                this.items = e.data
            })
        },
        del(idx){
            var id = this.items[idx].id
            console.log(id)
            const data = new URLSearchParams()
            data.append('address_id',id)
            axios.post('user.php?act=delete_address&ajax=true', data).then(r => {
                console.log(r)
            })
        },
        xingzen(){
            obj.id = ''
            obj.maxaddress = ''
            localStorage.setItem("lists",JSON.stringify(obj));
        },
        bianjis(idx){
            obj.id = this.items[idx].id
            obj.name = this.items[idx].name
            obj.tel = this.items[idx].tel
            obj.province = this.items[idx].province
            obj.city = this.items[idx].city
            obj.area = this.items[idx].area
            obj.status = this.items[idx].status
            obj.maxaddress = this.items[idx].province + '-' + this.items[idx].city + '-' + this.items[idx].area
            obj.address = this.items[idx].address
            localStorage.setItem("lists",JSON.stringify(obj));
        },
        init(){
            this.addpost()
        }
    },
    created() {
        this.init()
    }
})